<?php
  $link = mysql_connect('', 'admin_xbq', 'nihao')
      or die('Could not connect: ' . mysql_error());
  echo "Connected successfully\n";
  echo '<br /><br />';

  $query = "use test";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  $sql = "select * from department where department.depart_ID=".$_GET['d_id'];
  $result = mysql_query($sql) or die('Query failed: ' . mysql_error());
  $line = mysql_fetch_array($result, MYSQL_ASSOC)
?>

<div  align="center">
  <form action="edit_confirm1.php?d_id=<?php echo $_GET['d_id'];?>" method="post">
    <table align="center" width="400">
      <tr>
        <td class="style3">Department ID:</td>
        <td align="right" class="style3">
          <input name="id" type="text" value="<?php echo $line['depart_ID'];?>" />
        </td>
      </tr>
      <tr>
        <td class="style3">Department's short name:</td>
        <td align="right" class="style3">
          <input name="short_name" type="text" value="<?php echo $line['d_short_name'];?>" />
        </td>
      </tr>
      <tr>
        <td class="style3">Department's full name:</td>
        <td align="right" class="style3">
          <input  name="full_name" type="text" value="<?php echo $line['d_full_name'];?>" />
        </td>
      </tr>
      <tr>
        <td class="style3">Head of department:</td>
        <td align="right" class="style3">
          <input name="head" type="text" value="<?php echo $line['d_head_name'];?>" />
        </td>
      </tr>
      <tr>
        <td class="style3">Duty of department head:</td>
        <td align="right" class="style3">
          <select name="duty" value="<?php echo $line['d_head_duty'];?>">
            <option value="Professor"> Professor </option>
            <option value="Associate professor"> Associate professor </option>
            <option value="Old teacher"> Old teacher </option>
            <option value="Assistant"> Assistant </option>
          </select>
        </td>
      </tr>
      <tr>
        <td class="style3">Department phone:</td>
        <td align="right" class="style3">
          <input name="phone" type="text" value="<?php echo $line['phone'];?>" />
        </td>
      </tr>
      <tr>
        <td class="style3">Department e-mail:</td>
        <td align="right" class="style3">
          <input name="email" type="text" value="<?php echo $line['email'];?>" />
        </td>
      </tr>
      <tr>
        <td class="style3">Department homepage:</td>
        <td align="right" class="style3">
          <input name="page" type="text" value="<?php echo $line['depart_page'];?>" />
        </td>
      </tr>
      <tr>
        <td class="style3" align="right">
          <input name="add" type="button" value="Reset" />
        </td>
        <td align="left" class="style3">
          <input name="add" type="submit" value="Save" />
        </td>
      </tr>
    </table>
  </form>
</div>

<?php
  mysql_free_result($result);
  
  mysql_close($link);
?>
